package com.sright.bcard.mini.web.controller;

import com.sright.bcard.common.service.share.dto.page.PageParamRequest;
import com.sright.bcard.common.service.share.dto.enterprise.AddressDTO;
import com.sright.bcard.common.service.share.dto.enterprise.MaterialDTO;
import com.sright.bcard.enterprise.share.service.AddressService;
import com.sright.bcard.enterprise.share.service.CompanyService;
import com.sright.bcard.enterprise.share.service.IndustryService;
import com.sright.bcard.enterprise.share.service.MaterialService;
import com.sright.common.response.SrightResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 行业相关controller
 */
@RestController
@RequestMapping("/common")
public class IndustryController {

    @Autowired
    private IndustryService industryService;

    @Autowired
    private CompanyService companyService;

    @Autowired
    private AddressService addressService;

    @Autowired
    private MaterialService materialService;

    /**
     * 行业列表
     * @return
     */
    @GetMapping("/industry.json")
    public SrightResponse industryList() {
        return industryService.industryList();
    }

    /**
     * 获取公司名称列表
     * @param offset
     * @param limit
     * @param enterpriseId
     * @return
     */
    @GetMapping("/companys.json")
    public SrightResponse companyList(@RequestParam(value = "offset") Integer offset,
                                 @RequestParam(value = "limit") Integer limit,
                                 @RequestParam(value = "enterpriseId") Long enterpriseId) {
        PageParamRequest pageParamRequest = new PageParamRequest();
        pageParamRequest.setLimit(limit);
        pageParamRequest.setOffset(offset);
        pageParamRequest.setEnterpriseId(enterpriseId);
        return companyService.companyList(pageParamRequest);
    }

    /**
     * 获取企业地址列表
     * @param offset
     * @param limit
     * @param enterpriseId
     * @return
     */
    @GetMapping("/address.json")
    public SrightResponse addressList(@RequestParam(value = "offset") Integer offset,
                                   @RequestParam(value = "limit") Integer limit,
                                   @RequestParam(value = "enterpriseId") Long enterpriseId) {
        AddressDTO addressDTO = new AddressDTO();
        addressDTO.setEnterpriseId(enterpriseId);
        addressDTO.setLimit(limit);
        addressDTO.setOffset(offset);
        return addressService.addressList(addressDTO);
    }

    /**
     * 获取企业名片 logo素材 列表
     * @return
     */
    @GetMapping("/logo.json")
    public SrightResponse logoList() {
        MaterialDTO materialDTO = new MaterialDTO();
        return materialService.list(materialDTO);
    }

    /**
     * 获取企业名片 名片背景素材列表
     * @return
     */
    @GetMapping("/style.json")
    public SrightResponse styleList() {
        MaterialDTO materialDTO = new MaterialDTO();
        return materialService.list(materialDTO);
    }

}
